package domain

import (
	"time"
)

const (
	UserApplicationTableName = "user_applications"
)

const (
	UserApplicationFieldStatus = "Status"
	UserApplicationFieldForm   = "Form"
	UserApplicationFieldUser   = "User"
)
const (
	UserApplicationColumnNextUpdateTime = "next_update_time"
)

type UserApplication struct {
	ID             int64               `json:"id"`
	FormID         *int64              `json:"-"`
	UserID         int64               `json:"-" gorm:"not null"`
	StatusID       *int64              `json:"-"`
	Content        JSON                `json:"content" gorm:"type:json"`
	SourceForm     JSON                `json:"source_form" gorm:"type:json"`
	Form           *ClubForm           `json:"form" gorm:"foreignKey:FormID;constraint:OnUpdate:CASCADE,OnDelete:SET NULL"`
	User           User                `json:"user" gorm:"foreignKey:UserID;constraint:OnUpdate:CASCADE,OnDelete:CASCADE"`
	Status         *ClubFormStatusFlow `json:"status" gorm:"foreignKey:StatusID;constraint:OnUpdate:CASCADE,OnDelete:SET NULL"`
	NextUpdateTime *time.Time          `json:"next_update_time" gorm:"type:timestamp;"`
	CreatedAt      time.Time           `json:"created_at" `
	UpdatedAt      time.Time           `json:"updated_at" `
}

type UserApplicationDTO struct {
	ID             int64                  `json:"id"`
	FormID         *int64                 `json:"-"`
	UserID         int64                  `json:"-" gorm:"not null"`
	StatusID       *int64                 `json:"-"`
	Content        JSON                   `json:"content" gorm:"type:json"`
	SourceForm     JSON                   `json:"source_form" gorm:"type:json"`
	Form           *ClubFormDTO           `json:"form" gorm:"foreignKey:FormID;constraint:OnUpdate:CASCADE,OnDelete:SET NULL"`
	User           UserDTO                `json:"user" gorm:"foreignKey:UserID;constraint:OnUpdate:CASCADE,OnDelete:CASCADE"`
	Status         *ClubFormStatusFlowDTO `json:"status" gorm:"foreignKey:StatusID;constraint:OnUpdate:CASCADE,OnDelete:SET NULL"`
	NextUpdateTime *time.Time             `json:"next_update_time" gorm:"type:timestamp;"`
	CreatedAt      time.Time              `json:"created_at" `
	UpdatedAt      time.Time              `json:"updated_at" `
}
